/**
 * Copyright (c) 2013, FPX and/or its affiliates. All rights reserved.
 * Use, Copy is subject to authorized license.
 */
package com.fpx.open.platform.domain.track;

import java.util.ArrayList;
import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author dranson
 * @date 2013年11月26日
 */
@XmlRootElement(name = "tracesList")
public class TracesList {
    
    @NotNull
    @Valid
    private List<TracesElement> tracesElements;
    
    @XmlElement(name="tracesElement")
    public List<TracesElement> getTracesElements() {
        return tracesElements;
    }

    public void setTracesElements(List<TracesElement> tracesElements) {
        this.tracesElements = tracesElements;
    }
    
    public void addTracesElement(TracesElement tracesElement) {
        if (tracesElements == null) {
            tracesElements = new ArrayList<TracesElement>();
        }
        tracesElements.add(tracesElement);
    }

    @Override
    public String toString() {
        StringBuffer buf = new StringBuffer();
        if (tracesElements != null) {
            for (TracesElement tracesElement : tracesElements) {
                buf.append(tracesElement).append("; ");
            }
            if (buf.length() >= 2) {
                buf.setLength(buf.length() - 2);
            }
        }
        return "TracesList [tracesElements=" + buf + "]";
    }
}
